﻿<?php
	require_once("../config/config.php");

	if (isset($_GET['client'])){
	
		$db = new PDO(PDO_DSN, USER , PASSWD ) or die("échec de connexion au serveur");
		$db->exec("SET NAMES 'UTF8'");
		
		$sql = "select * from clients
				where cl_id = :id";
		$rq = $db->prepare($sql);
		$rq->bindParam(':id', $_GET['client'] );
		$rq->execute();
		
		$res = $rq->fetch();
		
		$nom    = $res["cl_nom"];
		$prenom = $res["cl_prenom"];
		$mail   = $res["cl_mail"];
		$statut = $res["cli_status"];
		$banque = $res["rib_banque"];
		$agence = $res["rib_agence"];
		$compte = $res["rib_cpte"];
		$cle    = $res["rib_cle"];
	}
?>

<h1> Modification client </h1>
<form id="form_modif_client" method="post" <?php echo "action='../lib/modifierClient.php?client=" . $_GET['client'] . "'"; ?> onsubmit="return main()">
		<table>
		<tr><td>Nom </td> <td><input id="nom" type="text" name="nom" <?php echo "value='$nom'"?> /> </td></tr>
		<tr><td>Prénom </td> <td><input id="prenom" type="text" name="prenom" <?php echo "value='$prenom'"?> /> </td></tr>
		<tr><td>Mail </td> <td><input id="mail" type="text" name="mail" <?php echo "value='$mail'"?> /></td></tr>
		<tr><td>Statut </td>
			<td><select name="statut" default="<?php echo "value='$statut'"?>">
				<option id="statut" name="statut" value="AR">AR</option>
				<option id="statut" name="statut" value="AR">PC</option>
				<option id="statut" name="statut" value="AR">OK</option>
			</select></td>
		</tr>
		<tr><td>RIB</td>
			<td><table>
				<tr><td>Banque</td><td>Agence</td><td>Compte</td><td>Cle</td></tr>
				<tr>
					<td> <input id="banque" type="text" name="banque" size="5" <?php echo "value='$banque'"?>/></td>
					<td> <input id="agence" type="text" name="agence" size="5" <?php echo "value='$agence'"?>/></td>
					<td> <input id="compte" type="text" name="compte" size="11" <?php echo "value='$compte'"?>/></td>
					<td> <input id="cle" type="text" name="cle" size="2" <?php echo "value='$cle'"?> /> </td>
				</tr>	
				</table>
			</td></tr>

		</table>
		
	
	<input id="buttonValidation" type="submit" name="Modifier" value="Modifier" />	
</form>